16. 合并数据集的结果

合并数据集的结果

使用下面的 notebook ,回答有关合并后数据集的最后一个问题。

问题 6: 对于 2008 年生产且 2018 年仍在生产中的车型,mpg 有多少改进,哪些车辆的改进最多?

以下是回答此问题的步骤。

1. 创建一个新的数据帧 model_mpg ,包含每个唯一车型在 2008 年和 2018 年的平均综合 mpg 值

要这样做,按车型分组,并找到每个车型的平均 cmb_mpg_2008 和平均 cmb_mpg

2. 创建一个新列 mpg_change ,包含 mpg 的变更

用 2018 年的平均 mpg 中减去 2008 年的平均 mpg,以获得 mpg 的变化值

3. 找到改进最多的车辆

找到最大的 mpg 变化值,然后使用查询或索引找到对应的车型!

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: jupyter
  • Opened files (when workspace is loaded): n/a